package com.hxtrip.zero.demo.rpc;

import com.hxtrip.zero.common.res.ApiErrorCode;
import com.hxtrip.zero.demo.po.Student;
import com.hxtrip.zero.demo.service.StudentService;
import com.hxtrip.zero.rpc.dto.StudentDto;
import com.hxtrip.zero.rpc.inter.IStudentBooth;
import com.hxtrip.zero.rpc.req.StudentReq;
import com.hxtrip.zero.rpc.res.StudentRes;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;

/**
 * 描述
 *
 * @author Hireek
 * @date 2022/3/7 22:46
 */
@DubboService
public class StudentBooth implements IStudentBooth {
    @Resource
    private StudentService studentService;

    @Override
    public StudentRes queryUserById(StudentReq req) {

        Student student = studentService.getById(req.getId());
        StudentDto studentDto = new StudentDto();
        studentDto.setId(student.getId());
        studentDto.setName(student.getName());
        return new StudentRes(ApiErrorCode.SUCCESS.getCode(), ApiErrorCode.SUCCESS.getMsg(), studentDto);
    }
}
